/* ****************************************************************
   ****************************************************************
   * Com++ Professional (c) 2009 C++ World
   * http://www.cplusplusworld.com/ mailto:compp@cplusplusworld.com
   ****************************************************************
   ****************************************************************
*/

#ifndef _SEM_H
#define _SEM_H

#include <semaphore.h>

#include <cstdio>
#include "ComPlusPlus/ShMem.h"

namespace compp {
class Sem
{
protected:
	sem_t *SemIdP;
	sem_t SemId;
	ShMem *sm;
public:
	Sem( bool remote = false, const int id = 0);
	Sem(int Val, bool remote = false, const int id = 0);
	virtual ~Sem();
	bool Post();
	bool Post(int count);
	bool Wait();
	bool TryWait();
	int Wait(int count);
};
}
#endif
